package abaco.gui;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JApplet;
import javax.swing.JFrame;
/**
 * 
 * @author Bruno Ferreira <brunosfweb@gmail.com>
 * @author Renan Barbosa  <renandelima@gmail.com>
 * 
 */
public class Stage extends JFrame implements ActionListener, ItemListener {
	private Workspace workspace;
	private JApplet   applet;
	private Container content;
	/**
	 * 
	 * @param applet
	 */
	public Stage(JApplet applet) {
		// initializes the JFrame, sending a title
		super ("Main Stage");
		//receives the instance of the Applet
		this.applet = applet;
		//initializes all components necessary for the construction of the editor
		init();
		//set the Layout for the Applet(frame);
		content.setLayout(new GridLayout(1,3));
		content.add(applet);
		setSize(700,600);
		pack();
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}
	/**
	 * 
	 */
	private void init() {
		//captures the panel that will the components and contents
		content = getContentPane();
		// initialize the instance of Panel(workspace)
		workspace = new Workspace();
	}
	/**
	 * 
	 */
	@Override
	public void itemStateChanged(ItemEvent event) {
		String command = event.getItem().toString();
		if (command.equals("Quit"))
			dispose ();
	}	
	/**
	 * 
	 */
	@Override
	public void actionPerformed(ActionEvent event) {
		String command = event.getActionCommand ();
		if (command.equals("Quit")) {
			//applet.close();
		} 	
	}
}
